package com.c.ctgproject.adapter.file

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.c.ctgproject.R
import com.c.ctgproject.base.BaseEmptyRecyclerViewAdapter
import com.c.ctgproject.entity.file.SecondExamineCarEntity
import com.c.ctgproject.utils.handlerNull
import java.lang.StringBuilder

class FileWaitPthotoAdapter(private val context: Context, private val mList: ArrayList<SecondExamineCarEntity.DataBean.ListBean>, private val listener:CarCallback) : BaseEmptyRecyclerViewAdapter<SecondExamineCarEntity.DataBean.ListBean>(context, mList) {
    override fun createViewHolder(parent: ViewGroup): RecyclerView.ViewHolder {
        val view = LayoutInflater.from(context).inflate(R.layout.item_wait_photo_list, parent, false)
        return MyViewHolder(view)
    }

    override fun handlerData(holder: RecyclerView.ViewHolder, position: Int) {
        if (holder is MyViewHolder) {
            val data = mList[position]
            val carPlate = StringBuilder(data.ownerPlate.handlerNull())
            holder.mCarPlateTV.text=carPlate

            //点击事件
            holder.mCarLL.setOnClickListener {
                listener.onItemClick(data.carCode.handlerNull())
            }
        }
    }

    inner class MyViewHolder(view: View) : RecyclerView.ViewHolder(view) {
       val mCarPlateTV:TextView=view.findViewById(R.id.mCarPlateTV)
       val mCarLL:LinearLayout=view.findViewById(R.id.mCarLL)
    }

    interface CarCallback {
        fun onItemClick(carCode: String)
    }
}